﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace GoShopping.BLL
{
    /// <summary>
    /// 数据库相关
    /// <remarks>采用Singleton单例模式</remarks>
    /// </summary>
    public static class Databases
    {
        #region 数据库连接串名字
        private const string CONNECTSTRINGNAME_GS = "GoShoppingConnectionString";
        private const string CONNECTSTRINGNAME_GSMEMBERSHIP = "GoShoppingMembershipConnection";
        private const string CONNECTSTRINGNAME_GSORDER = "GoShoppingOrderConnectionString";
        #endregion

        #region DataBaseInstance
        //public static readonly NBearLite.Database DBGoShopping = new NBearLite.Database("GoShoppingConnectionString");
        /// <summary>
        /// GoShopping数据库实例
        /// </summary>
        public static readonly NBearLite.Database DBGoShopping = new NBearLite.Database(CONNECTSTRINGNAME_GS);
        /// <summary>
        /// GoShoppingMember数据库实例
        /// </summary>
        public static readonly NBearLite.Database DBGoShoppingMember = new NBearLite.Database(CONNECTSTRINGNAME_GSMEMBERSHIP);
        /// <summary>
        /// 订单处理数据库实例
        /// </summary>
        public static readonly NBearLite.Database DBGoShoppingOrder = new NBearLite.Database(CONNECTSTRINGNAME_GSORDER);

        #endregion

        #region 调试用
        /// <summary>
        /// 将SQL打印到命令行
        /// </summary>
        public static void DebugSql()
        {
            DBGoShopping.OnLog += new NBearLite.LogHandler(DBGoShopping_OnLog);
        }

        static void DBGoShopping_OnLog(string logMsg)
        {
            string s = logMsg;
            System.Diagnostics.Debug.WriteLine(logMsg);
        }
        #endregion
    }
}
